package LeetCode;

/**
 * @Author Kechelle
 * @Date 2020/9/21 16:57
 * @Version 1.0
 */
public class Code58 {
    public static int lengthOfLastWord(String s){
        int count = 0;
        for (int i=s.length()-1;i>=0;i--){
            if (s.charAt(i) == ' '){
                if (count != 0) break;
                continue;
            }
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
        String s = "Hello World";
        System.out.println(lengthOfLastWord(s));
    }
}
